package com.gongpingjialoan.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.gongpingjialoan.R;
import com.gongpingjialoan.utility.BaseViewHolder;

/**
 * Created by Administrator on 2016/5/11.
 */
public class MaterialAdapter extends BaseAdapter {

    private Context mContext;

    public MaterialAdapter(Context context) {
        mContext = context;
    }

    private int[] drawables = {R.drawable.sfz, R.drawable.xsz, R.drawable.djz, R.drawable.gzs, R.drawable.cys
            , R.drawable.hbb, R.drawable.jqx, R.drawable.gcfp, R.drawable.jzb};

    private String[] names = {"身份证", "行驶证", "登记证", "购置税", "车钥匙", "环保标", "交强险", "购车发票", "检字标"};

    @Override
    public int getCount() {
        return 9;
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(
                    R.layout.sellcar_cailiao_item, null, false);
        }
        ImageView tv1 = BaseViewHolder.get(convertView, R.id.iv_item);
        TextView tv2 = BaseViewHolder.get(convertView, R.id.tv_item);
        tv1.setImageResource(drawables[position]);
        tv2.setText(names[position]);
        return convertView;
    }
}
